﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="TextBox">
        <Setter Property="Padding" Value="1,3"/>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>  <!-- Set an empty error template, hide the red rectangle -->
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="Background" Value="{StaticResource ErrorBackground}"/>
                <Setter Property="ToolTip">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource ValidationErrorsConverter}">
                            <Binding Path="(Validation.Errors)" RelativeSource="{RelativeSource Self}"/>
                            <Binding Path="(Validation.Errors).Count" RelativeSource="{RelativeSource Self}"/>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DarkTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Background" Value="{StaticResource DarkBackground}"/>
        <Setter Property="BorderBrush" Value="White"/>
        <Setter Property="SelectionBrush" Value="White"/>
        <Setter Property="Template">
            <!--
            Define an own TextBox template because the selection and mouse-over border color cannot be set otherwise. This template does not contain the triggers to change the border color.
            -->
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                        <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" TargetName="border" Value="0.56"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
                    <Condition Property="IsSelectionActive" Value="false"/>
                </MultiTrigger.Conditions>
                <Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>